package com.example.controller;

import com.example.pojo.*;
import com.example.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * ClassName:jobDescriptionController
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/9/11 20:21
 * @Version 1.0
 */
@RestController
@Slf4j
public class jobDescriptionController {
    //调入岗位List的Server
    @Autowired
    private postListService postListService;
    @Autowired
    private businessReportService businessReportService;
    //对岗位List插入一行数据
    @PostMapping("/insertPostListJobDescription")
    public Result insertPostListJobDescription(@RequestBody postListPojo pojo){
        //到Server层去进行插入操作,插入一行数据
        postListService.insertOne(pojo);
        return Result.success("插入成功");
    }
    //对岗位List根据某一个字段查询等于某一个值的所有值
    @PostMapping("/inquiryOneFieldValuePostListJobDescription")
    public Result inquiryOneFieldValuePostListJobDescription(@RequestBody Map<String,Object> map){
        //对岗位List根据某一个字段查询等于某一个值的所有值
        List<postListPojo> pojos=postListService.inquiryOneFieldValue(map);
        return Result.success(pojos);
    }
    //辅助函数：岗位List表中，修改一行数据
    @PostMapping("/editOnePostListJobDescription")
    public Result editOnePostListJobDescription(@RequestBody postListPojo pojo){
        //辅助函数：岗位List表中，修改一行数据
        postListService.editOneRow(pojo);
        return Result.success("修改成功");
    }
    //辅助函数：对业务汇报中，根据某一个字段查询等于某一值的函数
    @PostMapping("/inquiryBusinessReportOneFiledJobDescription")
    public Result inquiryBusinessReportOneFiledJobDescription(@RequestBody Map<String,Object> map){
        List<businessReportPojo> pojos=businessReportService.inquiryBusinessReportOneFiled(map);
        return Result.success(pojos);
    }
    //辅助函数：对业务汇报中，插入一条数据，所有字段都插入
    @PostMapping("/insertBusinessReportOneJobDescription")
    public Result insertBusinessReportOneJobDescription(@RequestBody businessReportPojo pojo){
        businessReportService.insertOne(pojo);
        return Result.success("插入成功");
    }
    //辅助函数：向业务汇报的表中根据id，修改一行数据
    @PostMapping("/editBusinessReportOneRowJobDescription")
    public Result editBusinessReportOneRowJobDescription(@RequestBody businessReportPojo pojo){
        //辅助函数：向业务汇报的表中根据id，修改一行数据
        businessReportService.editOneRowById(pojo);
        return Result.success("修改成功");
    }
    //向清洁度的表中插入一行数据
    @Autowired
    private pokaYokeIdentifyService pokaYokeIdentifyService;
    //插入一条防错分析数据
    @PostMapping("/insertPokaYokaJobDescription")
    public Result insertPokaYokaJobDescription(@RequestBody pokaYokeIdentifyPojo pojo){
        pokaYokeIdentifyService.insertOne(pojo);
        return Result.success("插入成功");
    }
    //修改一条防错数据
    @PostMapping("/editPokaYokaJobDescription")
    public Result editPokaYokaJobDescription(@RequestBody pokaYokeIdentifyPojo pojo){
        //向后端传递数据
        pokaYokeIdentifyService.editOneRow(pojo);
        return Result.success("修改成功");
    }
    //多条件筛选防错分析表
    @PostMapping("/filterPokaYokJobDescription")
    public Result filterPokaYokJobDescription(@RequestBody Map<String,Object> map){
        queryResult queryResult=pokaYokeIdentifyService.filterPokaYok(map);
        return Result.success(queryResult);
    }
    //筛选出岗位名称
    @Autowired
    private postNameListService postNameListService;
    //查询所有的岗位
    @PostMapping("/inquiryPostNameListJobDescription")
    public Result inquiryPostNameListJobDescription(){
        List<postNameListPojo> pojo= postNameListService.inquiryAll();
        return Result.success(pojo);
    }
    @Autowired
    private businessNameService businessNameService;
    //辅助函数：读取业务汇报的明细,调出所有的名字
    @PostMapping("/inquiryBusinessNameListJobDescription")
    public Result inquiryBusinessNameListJobDescription(){
        List<businessNamePojo> pojos = businessNameService.inquiryAll();
        return Result.success(pojos);
    }
}
